package com.recruit.g1.job.service.impl;

import com.recruit.g1.job.mapper.InterestedJobsMapper;
import com.recruit.g1.job.service.InterestedJobsService;
import com.recruit.g1.pojo.job.entity.Job;
import com.recruit.g1.pojo.user.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.List;

@Slf4j
@Service
public class InterestedJobsServiceImpl implements InterestedJobsService {
    @Autowired
    InterestedJobsMapper interestedJobsMapper;
    @Override
    public List<Job> selectInterestedJobs(Long userId) {
        log.debug("InterestedJobsServiceImpl的selectInterestedJobs()的查询条件userId的值为{}",userId);
        List<Job> list = interestedJobsMapper.selectInterestedJobs(userId);
        log.debug("list的值为{}",list);
        return list;
    }

    @Override
    public List<Job> selectInterestedJob(Long userId, Long jobId) {
        log.debug("传过来的userID的值为"+userId+"传过来的jobId的值为"+jobId);
        List<Job> list = interestedJobsMapper.selectInterestedJob(userId, jobId);
        log.debug("list的值为{}",list);
        return list;
    }

    //本方法因为没有处理user模块登录成功，本模块获取不到登录用户的问题，所以本方法目前还无法使用
    @Override
    public void deleteInterestedJobs(Long jobId, HttpSession session) {
        User user=(User)session.getAttribute("currentLoginUser");
        log.debug("传过来的jobId的值为"+jobId);
        interestedJobsMapper.deleteInterestedJobs(jobId, user.getId());
    }
}
